/*
*Copyright (C) 2007-2011 Borqs Ltd. All rights reserved.
*/
package com.borqs.music.util;

import java.util.Hashtable;

import android.util.Log;

/**
 * Utility log tool.
 * 
 * @author 
 * 
 */
public class MyLogger {

    private static boolean sIsLoggerEnable = true;
    private final static String LOG_TAG = "[BorqsMusic]";
    private static Hashtable<String, MyLogger> sLoggerTable;

    static {
        sLoggerTable = new Hashtable<String, MyLogger>();
    }

    private String mClassName;

    public static MyLogger getLogger(String className) {
        MyLogger classLogger = (MyLogger) sLoggerTable.get(className);
        if (classLogger == null) {
            classLogger = new MyLogger(className);
            sLoggerTable.put(className, classLogger);
        }
        return classLogger;
    }

    private MyLogger(String name) {
        mClassName = name;
    }

    public void v(String log) {
        if (sIsLoggerEnable) {
            Log.v(LOG_TAG, "{Thread:" + Thread.currentThread().getName() + "}[" + mClassName + ":] " + log);
        }
    }

    public void d(String log) {
        if (sIsLoggerEnable) {
            Log.d(LOG_TAG, "{Thread:" + Thread.currentThread().getName() + "}[" + mClassName + ":] " + log);
        }
    }

    public void i(String log) {
        if (sIsLoggerEnable) {
            Log.i(LOG_TAG, "{Thread:" + Thread.currentThread().getName() + "}[" + mClassName + ":] " + log);
        }
    }

    public void w(String log) {
        if (sIsLoggerEnable) {
            Log.w(LOG_TAG, "{Thread:" + Thread.currentThread().getName() + "}[" + mClassName + ":] " + log);
        }
    }

    public void e(String log) {
        Log.e(LOG_TAG, "{Thread:" + Thread.currentThread().getName() + "}[" + mClassName + ":] " + log);
    }
}
